package com.qinsoft.frame.messages;

import java.util.ArrayList;
import java.util.List;

import com.qinsoft.frame.exception.ApiException;

/** 
 * ResultMessage类描述：执行返回信息对象
 */
public class ResultMessage
{

    private boolean succeed = true;     //执行是否成功
    private Object result;              //返回执行结果
    private List<String> errList = new ArrayList<String>();

    /**
     * 操作执行是否成功
     */
    public boolean getSucceed()
    {
        return succeed;
    }

    /**
     * 操作执行是否成功
     */
    public void setSucceed(boolean isSucceed)
    {
        this.succeed = isSucceed;
    }

    public Object getResult()
    {
        return result;
    }

    public void setResult(Object result)
    {
        this.result = result;
    }

    public List<String> getErrList()
    {
        return errList;
    }

    public void setErrList(List<String> errList)
    {
        this.errList = errList;
    }

    /**
     * 添加单个错误信息
     */
    public void addError(String msg)
    {
        this.succeed = false;
        this.errList.add(msg);
    }

    /**
     * 添加多个错误信息
     */
    public void addErrors(List<String> msg)
    {
        this.succeed = false;
        for (int i = 0; i < msg.size(); i++)
        {
            this.errList.add(msg.get(i));
        }
    }
    
    /**
     * 添加异常信息
     */
    public void addException(ApiException e)
    {
        this.succeed = false;
        this.errList.add(e.getMessage());
    }
}
